<template>
  <div id="sellHeader">
    <!-- 遮罩 -->
    <div class="top">
      <div class="mask"></div>
      <img class="bg" src="../assets/imgs/bg.jpg" alt="" />
    </div>
    <!-- 顶部商家信息 -->
    <div class="shop-info">
      <!-- 左侧商家头像 -->
      <img class="logo" v-if="info.avatar" :src="info.avatar" alt="" />
      <!-- 右侧商家简介 -->
      <div class="info">
        <div class="name">
          <svg class="icon" aria-hidden="true">
            <use xlink:href="#icon-pinpai1"></use></svg
          >{{ info.name }}
        </div>
        <div class="desc">{{ info.description }}</div>
        <div class="supports" v-if="info.supports">
          <svg class="manjianyouhui" aria-hidden="true">
            <use xlink:href="#icon-manjianyouhui"></use>
          </svg>
          {{ info.supports.join(" / ") }}
        </div>
      </div>
      <!-- 右下角活动数量 -->
      <div class="count" v-if="info.supports">
        {{ info.supports.length }}个&gt;
      </div>
    </div>
    <!-- 商家公告 -->
    <van-notice-bar
      class="iconfont icon-gonggao"
      @click="handleChangeVisible(true)"
      :text="info.bulletin"
    />

    <transition name="fade">
      <div v-show="flag" class="shop-show">
        <div class="name">{{ info.name }}</div>
        <van-rate
          v-model="info.score"
          :size="25"
          color="#ffd21e"
          :allow-half="true"
          void-icon="star"
          void-color="#eee"
          class="rate"
        />
        <van-divider class="data">优惠信息</van-divider>
        <div class="font" v-for="item in info.supports" :key="item">
          <i class="iconfont icon-manjianyouhui"></i>{{ item }}
        </div>
        <van-divider class="data">商家公告</van-divider>
        <div class="info">{{ info.bulletin }}</div>
        <br />
        <i
          @click="handleChangeVisible(false)"
          class="pose iconfont icon-shanchu"
        ></i>
      </div>
    </transition>
  </div>
</template>

<script>
export default {
  props: ['info'],
  data () {
    return {
      // show: false,
      flag: false
    }
  },
  // 最优解决方案
  watch: {
    info: {
      handler () {

      },
      deep: true
    }
  },
  methods: {
    // 控制商家详情弹层显示或隐藏
    handleChangeVisible (flag) {
      this.flag = flag
    }
  },
}
</script>

<style lang="less" scoped>
#sellHeader {
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  .top {
    .mask {
      position: absolute;
      width: 100%;
      height: 150px;
      background-color: rgba(0, 0, 0, 0.5);
      z-index: -5;
      backdrop-filter: blur(5px);
    }
    .bg {
      position: absolute;
      width: 100%;
      height: 150px;
      z-index: -10;
    }
  }
  .shop-info {
    position: relative;
    box-sizing: border-box;
    display: flex;
    padding: 20px;
    .logo {
      width: 80px;
      height: 80px;
      border-radius: 6px;
    }
    .info {
      color: #fff;
      margin-left: 15px;
      line-height: 25px;
      .name {
        font-size: 20px;
        font-weight: 700;
        .iconfont {
          color: red;
          font-size: 23px;
        }
      }
      .desc {
        font-size: 14px;
      }
      .supports {
        font-size: 12px;
        line-height: 15px;
      }
    }
    .count {
      position: absolute;
      bottom: 5px;
      right: 20px;
      width: 40px;
      height: 25px;
      line-height: 25px;
      border-radius: 13px;
      font-size: 12px;
      text-align: center;
      color: #fff;
      background-color: #333;
    }
  }
  .van-notice-bar {
    position: absolute;
    bottom: 0;
    color: white;
    width: 100%;
    height: 30px;
    font-size: 12px;
    background-color: rgba(0, 0, 0, 0.5);
  }
  .shop-show {
    padding: 20px;
    box-sizing: border-box;
    position: fixed;
    top: 0;
    color: white;
    z-index: 100;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.8);
    .name {
      text-align: center;
      font-size: 30px;
      line-height: 48px;
    }
    .data {
      font-size: 24px;
      font-weight: 700;
      color: white;
    }
    .rate {
      display: flex;
      justify-content: center;
    }
    .pose {
      font-size: 50px;
      position: absolute;
      top: 70%;
      left: 50%;
      transform: translateX(-50%);
    }
    .info {
      line-height: 24px;
    }
    .font {
      margin-bottom: 10px;
      .iconfont {
        font-size: 25px;
        padding-right: 5px;
      }
    }
  }
}
.icon {
  width: 2em;
  height: 1em;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
.manjianyouhui {
  width: 1.5em;
  height: 1.5em;
  fill: white;
  overflow: hidden;
}
</style>